﻿using System.Drawing;
using System.Drawing.Drawing2D;

namespace Letspirate.Utilities.Helpers
{
    public static class BitmapHelper
    {
        public static Bitmap Resize(Bitmap source, Size newSize, InterpolationMode interpolationMode)
        {
            return Resize(source, newSize.Width, newSize.Height, interpolationMode);
        }

        public static Bitmap Resize(Bitmap source, int newWidth, int newHeight, InterpolationMode interpolationMode)
        {
            var resizedImage = new Bitmap(newWidth, newHeight);
            using (var graphics = Graphics.FromImage(resizedImage))
            {
                graphics.InterpolationMode = interpolationMode;
                graphics.DrawImage(source, 0, 0, newWidth, newHeight);
                graphics.Save();
            }

            return resizedImage;
        }
    }
}
